/*
 * @Descripttion:
 * @version:
 * @Author: kl2018
 * @Date: 2019-12-04 15:14:43
 * @LastEditors: kl2018
 * @LastEditTime: 2020-08-10 14:45:24
 */
import React, { Component } from 'react';
import { WeaTop, WeaTab, WeaNewScroll, WeaLocaleProvider, WeaRightMenu } from 'ecCom';
import { Button } from 'antd';
import { observer, inject } from 'mobx-react';
import { WeaTableNew } from 'comsMobx';

const getLabel = WeaLocaleProvider.getLabel;
const WeaTable = WeaTableNew.WeaTable;
let recPostLogStore = {};

@inject('recPostLogStore')
@observer
class AlterLog extends Component {
  constructor(props) {
    super(props);
    recPostLogStore = this.props.recPostLogStore;
  }
  componentDidMount() {
    recPostLogStore.getLogTableData();
    recPostLogStore.getTabData();
    recPostLogStore.getSearchForm();
  }
  getTabButtonsAd() {
    return [
      (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@iwj1rg@search`} type="primary" onClick={recPostLogStore.getSearchData}>{getLabel(388113, '搜索')}</Button>),
      (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@9wgu5m@reset`} type="ghost" onClick={() => recPostLogStore.SearchForm.resetForm()}>{getLabel(2022, '重置')}</Button>),
      (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@ll8ma2@cancel`} type="ghost" onClick={() => recPostLogStore.showSearchAd = false}>{getLabel(31129, '取消')}</Button>),
    ];
  }

  getSearchForm() {
    const SearchForm = recPostLogStore.SearchForm;
    return (
      <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@bwgdhg`} ref="scroll">
        {SearchForm.render({ needTigger: true })}
      </WeaNewScroll>
    );
  }
  getRightMenu() {
    const tableStore = recPostLogStore.logTable.tableStore;
    const rightMenuDatas = [{
      key: '1',
      disabled: false,
      icon: <i className="icon-coms-Add-to" />,
      content: getLabel('387597', '导出EXCLE'),
      onClick: () => tableStore.exportCurrent(),
    }];
    return rightMenuDatas;
  }

  render() {
    const tableStore = recPostLogStore.logTable.tableStore;
    return (
      <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@6gwgcg`} datas={this.getRightMenu()}>
        <div className="alterLogtop">
          <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@lasyev`}
            title={<span style={{ color: '#333333' }}>{getLabel(387598, '收发文日志')}</span>}
            icon={<i className="icon-coms-rizhizhongxin" />}
            iconBgcolor="#0079DE"
            buttons={[<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@vrb79x@export`} type="primary" onClick={() => tableStore.exportCurrent()}>{getLabel(387597, '导出EXCLE')}</Button>]}
          >
            <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@yp594i`}
              datas={recPostLogStore.topTab}
              selectedKey={recPostLogStore.selectedKey}
              searchType={['advanced']}
              showSearchAd={recPostLogStore.showSearchAd}
              setShowSearchAd={bool => recPostLogStore.showtTag(bool)}
              buttonsAd={this.getTabButtonsAd()}
              searchsAd={this.getSearchForm()}
              keyParam="viewcondition" // 主键
              onChange={(v) => {
                recPostLogStore.changeDate(v);
              }}
              advanceHeight={'auto'}
            />
            <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@yt3rh3`} comsWeaTableStore={tableStore} needScroll={true} />
          </WeaTop>
        </div>
      </WeaRightMenu>
    );
  }
}
export default AlterLog;
